#include <iostream>
#include <GL/glew.h>
#include "Display.h"
#include "Shader.h"
#include "Mesh.h"
#include "Texture.h"
#include "Camera.h"
#include "Transform.h"
#include "MyMesh.h"

int main(int argc, char ** argv)
{
	Display display(800, 600, "OpenGL Tutorials");
	Mesh * mesh = new Mesh();
	if (!mesh->LoadMesh("../../Resources/Models/rifle.obj"))
		std::cout << "Mesh could not load correctly" << std::endl;

	//MyMesh mesh("../../Resources/Models/torusBlender.obj");


	Shader * shader = new Shader("../../Resources/Shaders/basicShader");
	//MyTexture texture("../../Resources/Images/texture2.jpg");
	Transform transform;
	Camera camera(glm::vec3(0.0f, 0.0f, -152.0f), 90.0f, (float)800 / (float)600, 0.1f, 500.0f);

	//transform.GetRot()->y = 180;
	SDL_Event e;
	bool isRunning = true;
	float counter = 0.0f;
	while (isRunning)
	{
		while (SDL_PollEvent(&e))
		{
			if (e.type == SDL_QUIT)
				isRunning = false;

		}

		display.Clear(0.50f, 0.5f, 0.5f, 1.0f);
		
		float sinCounter = sinf(counter);
		float absSinCounter = abs(sinCounter);
		
		transform.GetPos()->x = sinCounter;
		transform.GetRot()->y = counter * 10;

		shader->Bind();
		//texture.Bind();
		shader->Update(transform, camera);		
		//mesh.Draw();
		mesh->Render();
		display.SwapBuffers();
		SDL_Delay(1);
		counter += 0.011f;
	}
	
	return 0;

}
